home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / General tools / Report Error 2.0 / TestReportError.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-17  |  2.4 KB  |  119 lines  |  [TEXT/KAHL]

  1. /*================================================================================
  2.     testReportError.c
  3.     
  4.     A simple test of the 'ReportError' package
  5. ================================================================================*/
  6. #include "reportError.h"
  7.  
  8. #ifndef __FAILUREHANDLER__
  9. #include "FailureHandler.h"
  10. #endif
  11. #ifndef __SHOWSTACKCHAIN__
  12. #include "ShowStackChain.h"
  13. #endif
  14.  
  15. /*
  16. // Macintosh includes
  17. */
  18. #ifndef __TYPES__
  19.     #include <Types.h>
  20. #endif
  21. /*
  22. //#ifndef __SYSEQU__
  23. //    #include <SysEqu.h>
  24. //#endif
  25. */
  26. #ifndef __ERRORS__
  27.     #include <Errors.h>
  28. #endif
  29. #ifndef __MEMORY__
  30.     #include <Memory.h>
  31. #endif
  32. #ifndef __MENUS__
  33.     #include <Menus.h>
  34. #endif
  35. #ifndef __FONTS__
  36.     #include <Fonts.h>
  37. #endif
  38. #ifndef __EVENTS__
  39.     #include <Events.h>
  40. #endif
  41. #ifndef __OSEVENTS__
  42.     #include <OSEvents.h>
  43. #endif
  44. #ifndef __DIALOGS__
  45.     #include <Dialogs.h>
  46. #endif
  47. #ifndef __TEXTEDIT__
  48.     #include <TextEdit.h>
  49. #endif
  50. #ifndef __WINDOWS__
  51.     #include <Windows.h>
  52. #endif
  53.  
  54. void InitAll(void);
  55. Handle TryToGetMemory(void);
  56. void TestReportError(void);
  57.  
  58. /*--------------------------------------------------------------------------------
  59.     Initialize all of the relivant Macintosh managers
  60. --------------------------------------------------------------------------------*/
  61. void InitAll()
  62. {
  63.     MaxApplZone();
  64.     
  65.     InitGraf( &(qd.thePort) );
  66.     InitFonts();
  67.     FlushEvents(everyEvent, 0);
  68.     InitWindows();
  69.     InitMenus();
  70.     TEInit();
  71.     InitDialogs(0L);
  72.     
  73.     InitCursor();
  74. }
  75.  
  76.  
  77. /*--------------------------------------------------------------------------------
  78.     Test the failure handler
  79. --------------------------------------------------------------------------------*/
  80. Handle TryToGetMemory()
  81. {
  82.     Handle testHandle = nil;
  83.     
  84.     testHandle = NewHandle( 0x7FFFFFFF );
  85.     FailMemError();
  86.     
  87.     return testHandle;
  88. }
  89.  
  90.  
  91. /*--------------------------------------------------------------------------------
  92.     Test the report error dialog box
  93. --------------------------------------------------------------------------------*/
  94. void TestReportError()
  95. {
  96.     Handle            testHandle = nil;
  97.     
  98.     TRY
  99.     {
  100.         testHandle = TryToGetMemory();
  101.     }
  102.     EXCEPT
  103.     {
  104.         ReportError( (unsigned char*)"\pThe memory block could not be allocated", TheFailError() );
  105.     }
  106.     ENDTRY
  107. }
  108.  
  109.  
  110. /*--------------------------------------------------------------------------------
  111.     A short test of 'ReportError'
  112. --------------------------------------------------------------------------------*/
  113. main()
  114. {
  115.     InitAll();
  116.     InitShowStackChain();
  117.     TestReportError();
  118. }
  119.